package com.weiaibenpao.demo.chislim.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jaeger.library.StatusBarUtil;
import com.weiaibenpao.demo.chislim.R;

public class Li_Medal_Activity extends Activity{

    Intent intent;
    int n = 0;
    int dis = 0;
    ImageView backImg;
    TextView medalNum;

    ImageView imd_1;
    ImageView imd_2;
    ImageView imd_3;
    ImageView imd_4;
    ImageView imd_5;
    ImageView imd_6;
    ImageView imd_7;
    ImageView imd_8;
    ImageView imd_9;
    ImageView imd_10;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_li__medal_);
        StatusBarUtil.setColor(this , getResources().getColor(R.color.ku_bg ) , 0);
        intent = getIntent();
        dis = intent.getIntExtra("dis",0);

        backImg = (ImageView) findViewById(R.id.backImg);
        backImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        initView();
        setMedal();
    }

    public void initView(){
        medalNum = (TextView) findViewById(R.id.medalNum);
        imd_1 = (ImageView) findViewById(R.id.imd_1);
        imd_2 = (ImageView) findViewById(R.id.imd_2);
        imd_3 = (ImageView) findViewById(R.id.imd_3);
        imd_4 = (ImageView) findViewById(R.id.imd_4);
        imd_5 = (ImageView) findViewById(R.id.imd_5);
        imd_6 = (ImageView) findViewById(R.id.imd_6);
        imd_7 = (ImageView) findViewById(R.id.imd_7);
        imd_8 = (ImageView) findViewById(R.id.imd_8);
        imd_9 = (ImageView) findViewById(R.id.imd_9);
        imd_10 = (ImageView) findViewById(R.id.imd_10);
    }

    public void setMedal(){
        if(dis < 3){
            n = 0;
        }else if(dis >= 3 &&dis < 5){
            n = 1;
            imd_1.setImageResource(R.mipmap.im_1);
        }else if(dis >= 5 && dis < 10){
            n = 2;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
        }else if(dis >= 10 && dis < 21){
            n = 3;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
            imd_3.setImageResource(R.mipmap.im_3);
        }else if(dis >= 21 && dis < 42){
            n = 4;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
            imd_3.setImageResource(R.mipmap.im_3);
            imd_4.setImageResource(R.mipmap.im_4);
        }else if(dis >= 42 && dis < 50){
            n = 5;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
            imd_3.setImageResource(R.mipmap.im_3);
            imd_4.setImageResource(R.mipmap.im_4);
            imd_5.setImageResource(R.mipmap.im_5);
        }else if(dis >= 50 && dis < 100){
            n = 6;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
            imd_3.setImageResource(R.mipmap.im_3);
            imd_4.setImageResource(R.mipmap.im_4);
            imd_5.setImageResource(R.mipmap.im_5);
            imd_6.setImageResource(R.mipmap.im_6);
        }else if(dis >= 100 && dis < 300){
            n = 7;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
            imd_3.setImageResource(R.mipmap.im_3);
            imd_4.setImageResource(R.mipmap.im_4);
            imd_5.setImageResource(R.mipmap.im_5);
            imd_6.setImageResource(R.mipmap.im_6);
            imd_7.setImageResource(R.mipmap.im_7);
        }else if(dis >= 300 && dis < 500){
            n = 8;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
            imd_3.setImageResource(R.mipmap.im_3);
            imd_4.setImageResource(R.mipmap.im_4);
            imd_5.setImageResource(R.mipmap.im_5);
            imd_6.setImageResource(R.mipmap.im_6);
            imd_7.setImageResource(R.mipmap.im_7);
            imd_8.setImageResource(R.mipmap.im_8);
        }else if(dis >= 500 && dis < 1000){
            n = 9;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
            imd_3.setImageResource(R.mipmap.im_3);
            imd_4.setImageResource(R.mipmap.im_4);
            imd_5.setImageResource(R.mipmap.im_5);
            imd_6.setImageResource(R.mipmap.im_6);
            imd_7.setImageResource(R.mipmap.im_7);
            imd_8.setImageResource(R.mipmap.im_8);
            imd_9.setImageResource(R.mipmap.im_9);
        }else if(dis >= 1000){
            n = 10;
            imd_1.setImageResource(R.mipmap.im_1);
            imd_2.setImageResource(R.mipmap.im_2);
            imd_3.setImageResource(R.mipmap.im_3);
            imd_4.setImageResource(R.mipmap.im_4);
            imd_5.setImageResource(R.mipmap.im_5);
            imd_6.setImageResource(R.mipmap.im_6);
            imd_7.setImageResource(R.mipmap.im_7);
            imd_8.setImageResource(R.mipmap.im_8);
            imd_9.setImageResource(R.mipmap.im_9);
            imd_10.setImageResource(R.mipmap.im_10);
        }

        medalNum.setText("（已获得" + n + "枚）");
    }
}
